"use strict"

var ProtoBuf = require('protobufjs');

var builder = ProtoBuf.loadProtoFile("./person.proto")
var Test = builder.build('Test'); // namespace package Test
var Person = Test.Person;


var wzq = new Person({
	"name": "wzq",
	"age": 32,
	"id": 101,
	"addr": "cn"
});

// var byteBuffer = wzq.encode();
// console.log(byteBuffer.toString('hex'));
// var buffer = byteBuffer.toBuffer(); // var buffer = byteBuffer.toArrayBuffer(); 

var buffer = wzq.toBuffer(); 

// var socket = ...;  
// socket.send(buffer);
// or 

// ---------------------------------------
// decode 
// var buffer = ... ; received
var wzq2 = Person.decode(buffer);
console.log(wzq2);

